package cn.edu.sicnu.cs.lgy.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        bottom.setOnNavigationItemSelectedListener {//这是一个触发事件，表示选择列表里的选项
            when(it.itemId){//用ID进行选择
                R.id.first -> {
                    val transaction = supportFragmentManager.beginTransaction()//开启Fragment
                    transaction.replace(R.id.fragmentContainerView,BlankFragment1())//点击后的替换（跳转事件）
                    transaction.commit()//提交
                }
                R.id.second -> {
                    val transaction = supportFragmentManager.beginTransaction()
                    transaction.replace(R.id.fragmentContainerView,BlankFragment2())
                    transaction.commit()
                }
                R.id.third -> {
                    val transaction = supportFragmentManager.beginTransaction()
                    transaction.replace(R.id.fragmentContainerView,BlankFragmentList())
                    transaction.commit()
                }
            }
            true
        }
    }
}